﻿#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QObject>
#include <QApplication>
#include <QDateTime>
#include <QTimer>
#include <QTime>
#include <QMainWindow>
#include <dbHelper.h>
#include <QThread>
#include <dbHelper.h>
#include <StringListener.h>
#include <CommonHelper.h>
#include <QDebug>
#include "xlsxdocument.h"
#include <QFileDialog>
#include <QMouseEvent>
#include <dataAnalysisThread.h>
#include <eqptinfo.h>
#include <QMovie>
#include <tcpclient.h>
#include <QDesktopWidget>
#include "speechmodulethread.h"
#include <intListener.h>
#include <maintainpassword.h>
#include <tcpServer.h>
#include "dataanalysiswindow.h"
#include "ui_dataanalysiswindow.h"
#include "derivedata.h"
#include <dataAnalsisByJThread.h>
#include <tcts.h>
#include <ui_tcts.h>

namespace Ui {
class MainWindow;
}

typedef struct TimeHMS{
    qint32 hour;
    qint32 minute;
    qint32 second;
}TimeHMS;

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    static intListener experimentStatus;
    static intListener tcpStatus;
    static intListener speechflagkg;
    static intListener canRefChart;
    static intListener experimentStep;
    static intListener experimentCircle;
    static intListener startExperiment;
    static intListener tcpServerStatus;
    static intListener canAnalyData;
    static intListener startExperimentStatus;
    static bool reAnalyse;
    static bool isBzsy;

    static StringListener tempDataOne;
    static StringListener experimentTime;

    static int connectType;
    static int oldExperimentStatus;
    static int HoleNum;
    static int tempOrder;
    static double tempDataTwo;
    static double tempDataThree;
    static double tempDataFour;
    static double tempDataFive;
    static double tempDataSix;

    static QString experimentGuid;
    static QString experimentSaveDataPath;

    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

    bool subtractOneSecond();

signals:
    void changeSetUpWindow();
    void changeAmplWindow();
    void changeSampleWindow();
    void changeExpeWindow();
    void changeAnalyWindow();
    void changeExpInfoWindow();
    void changeExpTempWindow();
    void changeErrorWindow();
    void changeMaintainWindow();

private slots:
    void tempTimerUpdate();
    void on_pushButton_6_clicked();
    void on_pushButton_4_clicked();
    void on_pushButton_3_clicked();
    void on_pushButton_8_clicked();
    void on_pushButton_7_clicked();
    void on_returnBtn_clicked();

    void on_pushButton_9_clicked();

    void on_pushButton_5_clicked();

    void on_pushButton_clicked();

    void on_pushButton_2_clicked();

    void on_pushButton_10_clicked();

    void on_pushButton_12_clicked();

private:
    void showEvent(QShowEvent *event) override;
    void do_timer_timeout();

    void closeMovieLabel();
    void experimentStatusChanged();
    void tcpStatusChanged();
    void speechflagkgChanged();
    void tcpServerChanged();
    void dataAnalyse();
    void passwordchange();
    void recordRunTime();
private:
    Ui::MainWindow *ui;
    speechModuleThread* spmoduleth;
    derivedata *derivedata1;
    TimeHMS hms;
    TimeHMS expHms;
    QTimer* m_timer;
    QTimer* expTimer;
    QTimer* labelTimer;
    QTimer* runTimer;
    CommonHelper* common;
    QString CycleNum;
    TcpClient *tcpClient;
    TcpServer *tcpServer;
    QLabel *label;
    QLabel *labelw;
    QWidget *container;
    QMovie *tempMovie;
    QMovie *mainMovie;
    DataAnalysisThread* dataAnalyThread;
    DataAnalysisByJThread* dataAnalyJ;
};


#endif // MAINWINDOW_H
